/**
 * @file
 * @auth jinguangguo
 * @date 2017/1/18
 */

import Vue from 'vue';
import '../../common/commonFilter';
import '../../../grsc-base/directive/main';
import filter from '../../../grsc-base/util/filter';
import codeMap from '../../../grsc-base/common/codeMap';

// include相关
import '../../include/nav/nav';
import '../../include/footer/footer';

// alert & confirm & toast
import '../../../grsc-base/component/Toast/Toast';
import '../../../grsc-base/component/Alert/Alert';
import '../../../grsc-base/component/OffsetConfirm/OffsetConfirm';

window.CODE = codeMap;

// 东八区时间
Vue.prototype.ZONE = 8;
Vue.prototype.CURRENCY_RMB = 6.6;

Vue.prototype.$$filter = filter;

Vue.prototype.reload = function () {
    // this.$router.go({
    //     path: this.$route.path,
    //     force: true
    // });
    // this.$router.go(0);
    window.location.reload();
    
};

let lang = window.location.pathname.split('/')[1];  // us / es
let href = window.location.href;

(function () {

    if (lang !== 'us' && lang !== 'es' && lang !== 'hk' && lang !== 'cn') {
        lang = 'us';     // 默认使用cn
    }

    // add by jinguangguo @01/15
    // 如果当前路径具有/cn, 连接到对应的/hk目录下
    // if (lang === 'cn') {
    //     window.location.href = href.replace(`/cn/`, `/us/`);
    // }else if(lang === 'hk'){
    //     window.location.href = href.replace(`/hk/`, `/us/`);
    // }
})();

let app = {
    DEBUG: false,
    isNeedStat: true, // 是否需要埋点统计    true正式环境 需要买点
    LANG: lang,
    isPayLocked: false,     // 支付密码是否被锁定
    realAuth: { // 是否进行过实名认证
        requested: false,
        value: null
    },
    user: { // 当前登录用户的基本信息
        requested: false,
        value: null
    },
    abroad: true
};

if (href.indexOf('localhost') >= 0) {
    app.DEBUG = true;
}

// if (href.indexOf('localhost') >= 0 || href.indexOf('gdae2.dev.gpdax')>=0 ) {
//     app.isNeedStat = false;
// }

window.app = app;
